﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Website.Controllers;
using Website.Interfaces;
using Website.Models;

namespace Website.Tests
{
    [TestClass]
    public class HomeControllerTests
    {
        [TestMethod]
        public void IndexTest()
        {
            // Arrange
            var siteDefinition = new SiteDefinition { FrontPageImage = "FrontPageImage" };
            var artCollection = new Mock<IArtCollection>();
            var siteDefinitionManager = new Mock<ISiteDefinitionManager>();
            siteDefinitionManager.SetupGet(m => m.SiteDefinitions).Returns(siteDefinition);

            // Act
            var ctrlr = new HomeController(artCollection.Object, siteDefinitionManager.Object);

            var result = ctrlr.Index();


            // Assert
            artCollection.VerifyAll();
            siteDefinitionManager.VerifyAll();

            Assert.AreEqual(typeof(ViewResult), result.GetType());
            var frontimage = ((ViewResult)result).ViewBag.frontimage;
            Assert.AreEqual("FrontPageImage", frontimage);
        }

        [TestMethod]
        public void AboutTest()
        {
            // Arrange
            var siteDefinition = new SiteDefinition
                                     {
                                         AboutPage = new AboutPage
                                                         {
                                                             Caption = "Caption",
                                                             Text = "Text"
                                                         }
                                     };
            var artCollection = new Mock<IArtCollection>();
            var siteDefinitionManager = new Mock<ISiteDefinitionManager>();
            siteDefinitionManager.SetupGet(m => m.SiteDefinitions).Returns(siteDefinition);

            // Act
            var ctrlr = new HomeController(artCollection.Object, siteDefinitionManager.Object);
            var result = ctrlr.About();

            // Assert
            Assert.AreEqual(typeof(ViewResult), result.GetType());

            var model = ((ViewResult)result).Model as AboutPage;
            Assert.AreEqual(typeof(AboutPage), model.GetType());
            Assert.AreEqual("Caption", model.Caption);
            Assert.AreEqual("Text", model.Text);
        }

        [TestMethod]
        public void PaintingsTest()
        {
        }

        [TestMethod]
        public void LinksTest()
        {
        }
    }
}
